function [T, T_deriv]=construct_chebyshev(x_interest,K,a,b)

N=size(x_interest,1);

T=NaN*ones(N,K+1);
x_trans=-1 + 2*(x_interest-a)/(b-a);
T(:,1)=1;
T(:,2)=x_trans;

for kk=3:K+1
    T(:,kk)=2*x_trans.*T(:,kk-1) - T(:,kk-2);
end

T_deriv=NaN*T;
T_deriv(:,1)=0;
T_deriv(:,2)=2/(b-a);

for kk=3:K+1
    T_deriv(:,kk)=2*x_trans.*T_deriv(:,kk-1) + 4/(b-a)*T(:,kk-1) - T_deriv(:,kk-2);
end

    %
